package logic

import (
	"DataSrv/data"
	"DataSrv/global/model"
	"DataSrv/internal/svc"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoUploadLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoUploadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoUploadLogic {
	return &VideoUploadLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *VideoUploadLogic) VideoUpload(in *data.VideoUploadRequest) (*data.VideoUploadResponse, error) {
	// todo: add your logic here and delete this line
	var video = model.Video{
		Url:       in.Url,
		UserId:    int(in.UserId),
		TypeId:    int(in.TypeId),
		Title:     in.Title,
		Des:       in.Des,
		Address:   in.Address,
		Tag:       in.Tag,
		ClassesId: int(in.ClassesId),
		Len:       int(in.Len),
		IsVip:     int(in.IsVip),
		ViewCount: 0,
	}
	if err := model.DB.Create(&video).Error; err != nil {
		return nil, err
	}
	return &data.VideoUploadResponse{}, nil
}
